/**
 * Created by s-wangh on 2017/11/10.
 */
import {Component} from "@angular/core";
import {StockRecommendService} from "./stock-recommend.service";
import {ModalController} from "ionic-angular";
import {StockSearchPage} from "./stock-search/stock-search";
import {Storage} from '@ionic/storage';
@Component({
  selector: 'stock-recommend',
  templateUrl: 'stock-recommend.html',
  providers: [StockRecommendService]
})
export class StockRecommendPage {
  public startTime: any = "2016-01-01"; //开始时间
  public endTime: any = "";             //结束时间
  public date = new Date();
  public keyWord = '';                  //股票代码、名称 搜索关键字
  public moreString = '显示所有信息';
  public moreStringOne = '显示所有信息';
  public isShow: boolean = false;       //是否显示更多列表
  public isShow1: boolean = false;       //是否显示更多列表
  public orgId: any = '5555';
  public stockRecommend: any = '';      //最新金股推荐

  constructor(public modalCtrl: ModalController, public stockRecommendService: StockRecommendService, public storage: Storage) {
    //this.inintData();
  }

  inintData() {
    this.storage.get("userInfo").then((userInfo) => {
      console.log(userInfo.loginid+'@@@@@@@@@@@@@@');
      // this.personService.getIRMSIRMOrgid(this.item.value).subscribe((data) => {
      // this.getOrgid(userInfo.loginid);
      this.getStockRecommend();
    });

    // this.stockRecommend = this.stockRecommendService.getStockRecommend(this.orgId, '2001-11-11', '2017-11-16');
    // console.log("###"+this.orgId + '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
    // console.log(this.stockRecommend);
    // console.log('*************************');
    this.endTime = this.date.getFullYear() + "-" + (this.date.getMonth() + 1 > 9 ? this.date.getMonth() + 1 : "0" + this.date.getMonth() + 1) + "-" + (this.date.getDate() > 9 ? this.date.getDate() : "0" + this.date.getDate());

  }
  getOrgid(loginid){
    this.stockRecommendService.getOrgid(loginid).subscribe((data)=>{
      console.log("###"+'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
      console.log(data);
      console.log('*************************');
    });
  }

  getStockRecommend(){
    this.stockRecommendService.getStockRecommend(999010813,'2001-11-11', '2017-11-16').subscribe((data)=>{
      console.log("$$$$$$$$$$$$");
      console.log(data);
    });
  }

  showAll() {
    this.isShow = !this.isShow;
    if (this.isShow == true) {
      this.moreString = '收起';
    } else {
      this.moreString = '显示所有信息';
    }
  }
  showAllOne() {
    this.isShow1 = !this.isShow1;
    if (this.isShow1 == true) {
      this.moreStringOne = '收起';
    } else {
      this.moreStringOne = '显示所有信息';
    }
  }

  advancedSearch() {
    let queryModal = this.modalCtrl.create(StockSearchPage, {
      // "listType" : this.listType
    });
    queryModal.onWillDismiss(data => {
      if (data && data != "close") {
      }
    });
    queryModal.present();
  }
}
